﻿using RestSharp;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace ACSynologyHelper
{
    /// <summary>
    /// FileStation操作类
    /// </summary>
    public class FileStationHelper
    {
        public static SynologyResult Info()
        {
            SynologyConf.RRequest.Resource = "webapi/entry.cgi";
            SynologyConf.RRequest.Parameters.Clear();
            SynologyConf.RRequest.Parameters.AddRange(SynologyConf.ParameterCookies);
            SynologyConf.RRequest.AddParameter("api", "SYNO.FileStation.Info", ParameterType.GetOrPost);
            SynologyConf.RRequest.AddParameter("version", 1, ParameterType.GetOrPost);
            SynologyConf.RRequest.AddParameter("method", "get", ParameterType.GetOrPost);
            var r = SynologyConf.RClient.Execute(SynologyConf.RRequest, Method.GET);
            return JsonConvert.DeserializeObject<SynologyResult>(r.Content);
        }

        public static SynologyResult List()
        {
            SynologyConf.RRequest.Resource = "webapi/entry.cgi";
            SynologyConf.RRequest.Parameters.Clear();
            SynologyConf.RRequest.Parameters.AddRange(SynologyConf.ParameterCookies);
            SynologyConf.RRequest.AddParameter("api", "SYNO.FileStation.List", ParameterType.GetOrPost);
            SynologyConf.RRequest.AddParameter("version", "1", ParameterType.GetOrPost);
            SynologyConf.RRequest.AddParameter("method", "list_share", ParameterType.GetOrPost);
            var r = SynologyConf.RClient.Execute(SynologyConf.RRequest, Method.GET);
            return JsonConvert.DeserializeObject<SynologyResult>(r.Content);
        }
    }
}
